package com.zjs.thread.lock;

import lombok.Data;

/**
 * @Description 锁测试
 * @Author zhu_jinsheng[zhu_js@suixingpay.com]
 * @Date 2019/12/27 9:46
 * @Version 1.0
 */
public class LockTest {
    public static void main(String[] args) {
        Thread thread1 = new Thread(new LockThread());
        Thread thread2 = new Thread(new LockThread());
        Thread thread3 = new Thread(new LockThread());
        Thread thread4 = new Thread(new LockThread());
        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();
    }
}

@Data
class LockThread implements Runnable{
    private LockDemo lockDemo = new LockDemo();
    @Override
    public void run() {
        while (true) {
            lockDemo.optimisticLock(Thread.currentThread().getName());
        }
    }
}
